package com.mapper;

import com.model.User;
import com.vo.RegisterVO;
import org.apache.ibatis.annotations.*;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

@Mapper
public interface UserMapper{
    @Select("select * from user")
    public List<User> getUserList();

    @Select("select * from user where id=#{id}")
    public User getUserById(@Param("id") Long id);

    @Select("select * from user where email=#{email}")
    public User getUserByemail(@Param("email")String email);

    /**
     * 插入新用户信息
     * @param user 新用户对象
     * @return 插入成功 true 失败 false
     */
    @Insert("insert into user(email,password,username) values(#{email},#{password},#{username})")
    public User insertUser(User user);

    @Insert("insert into user(email,password,username) values(#{email},#{password},#{username})")
    public boolean registerUser(RegisterVO registerVO);

    /**
     * 修改用户信息
     * @param
     * @return
     */
    @Update("update user set email=password=#{password},username=#{username} where email=#{email}")
    public boolean updateUser(User user);

    @Select("select * from user where email=#{email} and password=#{password}")
    public User login(@Param("email") String email,@Param("password") String password);


}
